package 第四章作业.O407;

import java.util.Scanner;

public class Test5 {
    public static void main(String[] args){
        Scanner reader = new Scanner(System.in);
        System.out.println("请输入阶乘尾数n");
        int n = reader.nextInt();
        System.out.println(Factorial(n));
    }

    public static int Factorial(int n){
        int a = 0;
        for(int i = 1;i <= n;i++){
            int b = 1;
            for(int j = 1;j <=i;j++){
                b = b*j;
                a += b;
            }
        }
        return a;
    }
}
